package project.menu.mastermenu.listmenu;


import java.util.ArrayList;

import project.controllers.Messager;
import project.controllers.Printer;
import project.menu.IMenu;
import project.menu.IMenuItem;
import project.work.Navigator;
import controllers.IAutoservice;
import entities.IMaster;

public class MastersByEmployment implements IMenuItem {

	private String name = "Sort masters by employment";
	private final Integer id = 2;
	private static IMenu submenu;
	private Navigator navigator;
	
	public MastersByEmployment(){
		navigator=Navigator.getInstance();
	}

	public Integer getId() {
		return id;
	}

	
	public void action(IAutoservice autoservice) {
		ArrayList<IMaster>temp=autoservice.SortMasterByEmployment();
		for (IMaster master : temp) {
			if (master.getEmploymentMaster()) {
				Printer.printMessage(master.getNameMaster()+Messager.BUSY_MASTER);
			} else {
				Printer.printMessage(master.getNameMaster()+Messager.FREE_MASTER);
			}
		}
		navigator.drawMenu(submenu);
	}

	
	public String getNameItem() {
		return name;
	}

	
	public static void setSubmenu(IMenu menu){
		 submenu=menu;
	}

}
